
<!DOCTYPE html>
<html lang="zh-CN">

  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Python实现TCP/UDP透明代理方案</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/js/all.min.js"></script>
    <link href="https://fonts.googleapis.com/css2?family=Tiempos+Headline:wght@400;700&family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
    <style>
        :root {
            --primary: #2563eb;
            --secondary: #64748b;
            --accent: #f59e0b;
            --background: #f8fafc;
            --foreground: #1e293b;
            --muted: #f1f5f9;
        }

        body {
            font-family: 'Inter', sans-serif;
            background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
            color: var(--foreground);
            line-height: 1.7;
        }

        .serif-heading {
            font-family: 'Tiempos Headline', serif;
        }

        .toc-sidebar {
            position: fixed;
            top: 0;
            left: 0;
            width: 280px;
            height: 100vh;
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
            border-right: 1px solid #e2e8f0;
            z-index: 1000;
            overflow-y: auto;
            padding: 2rem 1.5rem;
        }

        .main-content {
            margin-left: 280px;
            min-height: 100vh;
        }

        .hero-section {
            background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
            color: white;
            position: relative;
            overflow: hidden;
        }

        .hero-overlay {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 1000"><defs><filter id="a"><feTurbulence baseFrequency="0.02" numOctaves="3" seed="5"/><feColorMatrix values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.1 0"/></filter></defs><rect width="100%" height="100%" filter="url(%23a)"/></svg>');
            opacity: 0.3;
        }

        .toc-link {
            transition: all 0.2s ease;
            border-left: 2px solid transparent;
            padding-left: 1rem;
        }

        .toc-link:hover, .toc-link.active {
            border-left-color: var(--primary);
            background: rgba(37, 99, 235, 0.05);
            color: var(--primary);
        }

        .section-card {
            background: white;
            border-radius: 12px;
            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
            border: 1px solid #e2e8f0;
            transition: all 0.3s ease;
        }

        .section-card:hover {
            box-shadow: 0 10px 25px -3px rgba(0, 0, 0, 0.1);
            transform: translateY(-2px);
        }

        .code-block {
            background: #1e293b;
            color: #e2e8f0;
            border-radius: 8px;
            overflow-x: auto;
        }

        .citation {
            color: var(--primary);
            text-decoration: none;
            font-weight: 500;
            border-bottom: 1px dotted var(--primary);
            transition: all 0.2s ease;
        }

        .citation:hover {
            background: rgba(37, 99, 235, 0.1);
            padding: 2px 4px;
            border-radius: 4px;
            border-bottom: none;
        }

        @media (max-width: 1024px) {
            .toc-sidebar {
                transform: translateX(-100%);
                transition: transform 0.3s ease;
            }

            .toc-sidebar.open {
                transform: translateX(0);
            }

            .main-content {
                margin-left: 0;
            }
        }
    </style>
  </head>

  <body>
    <!-- Table of Contents Sidebar -->
    <nav class="toc-sidebar">
      <div class="mb-8">
        <h2 class="serif-heading text-xl font-bold text-gray-900 mb-4">目录导航</h2>
        <div class="space-y-2">
          <a href="#hero" class="toc-link block py-2 text-sm font-medium text-gray-700 hover:text-blue-600">概述</a>
          <a href="#server-implementation" class="toc-link block py-2 text-sm font-medium text-gray-700 hover:text-blue-600">1. 服务器端实现</a>
          <div class="ml-4 space-y-1">
            <a href="#server-core" class="toc-link block py-1 text-xs text-gray-600 hover:text-blue-500">1.1 核心功能与架构</a>
            <a href="#server-challenges" class="toc-link block py-1 text-xs text-gray-600 hover:text-blue-500">1.2 技术选型与挑战</a>
            <a href="#server-code" class="toc-link block py-1 text-xs text-gray-600 hover:text-blue-500">1.3 代码实现方案</a>
          </div>
          <a href="#client-implementation" class="toc-link block py-2 text-sm font-medium text-gray-700 hover:text-blue-600">2. 客户端实现</a>
          <div class="ml-4 space-y-1">
            <a href="#client-core" class="toc-link block py-1 text-xs text-gray-600 hover:text-blue-500">2.1 核心功能与架构</a>
            <a href="#client-challenges" class="toc-link block py-1 text-xs text-gray-600 hover:text-blue-500">2.2 技术选型与挑战</a>
            <a href="#client-code" class="toc-link block py-1 text-xs text-gray-600 hover:text-blue-500">2.3 代码实现方案</a>
          </div>
          <a href="#tools-frameworks" class="toc-link block py-2 text-sm font-medium text-gray-700 hover:text-blue-600">3. 相关工具与框架</a>
          <a href="#implementation-summary" class="toc-link block py-2 text-sm font-medium text-gray-700 hover:text-blue-600">4. 实现总结</a>
        </div>
      </div>

      <div class="border-t pt-4">
        <p class="text-xs text-gray-500 mb-2">技术关键词</p>
        <div class="flex flex-wrap gap-1">
          <span class="px-2 py-1 bg-blue-100 text-blue-700 text-xs rounded">Python</span>
          <span class="px-2 py-1 bg-green-100 text-green-700 text-xs rounded">Socket</span>
          <span class="px-2 py-1 bg-purple-100 text-purple-700 text-xs rounded">Scapy</span>
          <span class="px-2 py-1 bg-yellow-100 text-yellow-700 text-xs rounded">PyDivert</span>
          <span class="px-2 py-1 bg-red-100 text-red-700 text-xs rounded">TCP/UDP</span>
        </div>
      </div>
    </nav>

    <!-- Main Content -->
    <main class="main-content">
      <!-- Hero Section -->
      <section id="hero" class="hero-section relative min-h-[70vh] flex items-center">
        <div class="hero-overlay"></div>
        <div class="container mx-auto px-4 sm:px-6 md:px-8 relative z-10">
          <div class="grid grid-cols-1 lg:grid-cols-12 gap-8 items-center">
            <!-- Title Section -->
            <div class="lg:col-span-7">
              <h1 class="serif-heading text-3xl sm:text-4xl md:text-5xl lg:text-6xl font-bold mb-6 leading-tight">
                <span class="italic text-amber-300">透明代理</span>
                <br>
                实现方案
              </h1>
              <p class="text-lg sm:text-xl text-blue-100 mb-8 leading-relaxed">
                基于Python的TCP/UDP透明代理完整解决方案，
                <br>
                涵盖服务器端与Windows客户端的深度技术实现
              </p>
              <div class="flex flex-wrap gap-4">
                <span class="px-3 py-1 sm:px-4 sm:py-2 bg-white/20 backdrop-blur-sm rounded-full text-sm font-medium">
                  <i class="fas fa-network-wired mr-2"></i>网络代理
                </span>
                <span class="px-3 py-1 sm:px-4 sm:py-2 bg-white/20 backdrop-blur-sm rounded-full text-sm font-medium">
                  <i class="fab fa-windows mr-2"></i>Windows平台
                </span>
                <span class="px-3 py-1 sm:px-4 sm:py-2 bg-white/20 backdrop-blur-sm rounded-full text-sm font-medium">
                  <i class="fab fa-python mr-2"></i>Python实现
                </span>
              </div>
            </div>

            <!-- Visual Element -->
            <div class="lg:col-span-5 mt-8 lg:mt-0">
              <div class="bg-white/10 backdrop-blur-sm rounded-2xl p-4 sm:p-6 border border-white/20">
                <img src="https://kimi-img.moonshot.cn/pub/icon/spinner.svg" alt="抽象网络数据流示意图" class="w-full rounded-lg mb-4 opacity-90" size="medium" aspect="wide" color="blue" query="抽象网络数据流" referrerpolicy="no-referrer" />
                <div class="text-center">
                  <p class="text-blue-100 text-sm font-medium">透明代理网络架构</p>
                  <p class="text-blue-200 text-xs mt-1">客户端 → 代理服务器 → 目标服务器</p>
                </div>
              </div>
            </div>
          </div>
        </div>
      </section>

      <!-- Server Implementation Section -->
      <section id="server-implementation" class="py-16 bg-white">
        <div class="container mx-auto px-8">
          <div class="max-w-4xl mx-auto">
            <div class="text-center mb-12">
              <h2 class="serif-heading text-4xl font-bold text-gray-900 mb-4">1. 服务器端：透明代理实现</h2>
              <p class="text-xl text-gray-600 leading-relaxed">作为透明网络流量中转站的核心组件，服务器端需要处理复杂的协议转发与地址保持问题</p>
            </div>

            <!-- Core Functionality -->
            <div id="server-core" class="section-card p-8 mb-12">
              <h3 class="serif-heading text-2xl font-bold text-gray-900 mb-6">1.1 核心功能与架构</h3>

              <div class="grid grid-cols-1 md:grid-cols-2 gap-8 mb-8">
                <div>
                  <h4 class="text-lg font-semibold text-gray-800 mb-4 flex items-center">
                    <i class="fas fa-server text-blue-500 mr-3"></i>
                    监听12345端口
                  </h4>
                  <p class="text-gray-600 mb-4">
                    服务器端的核心任务是作为一个透明的网络流量中转站。根据需求，它必须在指定的
                    <strong class="text-blue-600">12345端口</strong>上进行监听，以接收来自客户端重定向的所有网络数据包。
                  </p>
                  <div class="bg-blue-50 p-4 rounded-lg border-l-4 border-blue-500">
                    <p class="text-sm text-blue-800">
                      <i class="fas fa-info-circle mr-2"></i>
                      这个端口是客户端和服务器端之间通信的约定入口，所有需要被代理的流量都必须经过它。
                    </p>
                  </div>
                </div>

                <div>
                  <h4 class="text-lg font-semibold text-gray-800 mb-4 flex items-center">
                    <i class="fas fa-exchange-alt text-green-500 mr-3"></i>
                    支持TCP与UDP协议
                  </h4>
                  <p class="text-gray-600 mb-4">
                    为了满足不同应用程序的需求，服务器端必须同时支持<strong class="text-green-600">TCP和UDP</strong>两种主要的传输层协议。
                  </p>
                  <div class="space-y-3">
                    <div class="flex items-start">
                      <span class="inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-blue-100 text-blue-800 mr-3 mt-0.5">TCP</span>
                      <p class="text-sm text-gray-600">面向连接的协议，需要完整参与三次握手和四次挥手过程</p>
                    </div>
                    <div class="flex items-start">
                      <span class="inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-green-100 text-green-800 mr-3 mt-0.5">UDP</span>
                      <p class="text-sm text-gray-600">无连接的协议，需要维护会话表以正确处理响应</p>
                    </div>
                  </div>
                </div>
              </div>

              <div class="bg-gray-50 p-6 rounded-lg">
                <h4 class="text-lg font-semibold text-gray-800 mb-4 flex items-center">
                  <i class="fas fa-eye text-purple-500 mr-3"></i>
                  透明转发与源地址保持
                </h4>
                <p class="text-gray-600 mb-4">
                  <strong class="text-purple-600">透明转发</strong>是本项目最核心的要求。这意味着对于目标服务器而言，它接收到的连接请求或数据报看起来就像是直接来自原始客户端，而不是代理服务器。
                </p>
                <div class="grid grid-cols-1 md:grid-cols-3 gap-4">
                  <div class="text-center p-3 bg-white rounded-lg border">
                    <i class="fas fa-user text-blue-500 text-2xl mb-2"></i>
                    <p class="text-sm font-medium text-gray-700">原始客户端</p>
                    <p class="text-xs text-gray-500">保持源IP地址</p>
                  </div>
                  <div class="text-center p-3 bg-white rounded-lg border">
                    <i class="fas fa-arrow-right text-gray-400 text-2xl mb-2"></i>
                    <p class="text-sm font-medium text-gray-700">代理服务器</p>
                    <p class="text-xs text-gray-500">透明转发</p>
                  </div>
                  <div class="text-center p-3 bg-white rounded-lg border">
                    <i class="fas fa-server text-green-500 text-2xl mb-2"></i>
                    <p class="text-sm font-medium text-gray-700">目标服务器</p>
                    <p class="text-xs text-gray-500">看到原始客户端IP</p>
                  </div>
                </div>
              </div>
            </div>

            <!-- Technical Challenges -->
            <div id="server-challenges" class="section-card p-8 mb-12">
              <h3 class="serif-heading text-2xl font-bold text-gray-900 mb-6">1.2 技术选型与挑战</h3>

              <div class="mb-8">
                <h4 class="text-lg font-semibold text-gray-800 mb-4">基于
                  <code class="bg-gray-100 px-2 py-1 rounded text-sm">socket</code>的代理实现
                </h4>
                <p class="text-gray-600 mb-4">
                  在构建透明代理服务器时，最直接和基础的技术选型是利用Python内置的
                  <code class="bg-gray-100 px-2 py-1 rounded">socket</code>模块。该模块提供了对BSD套接字接口的访问，允许开发者创建客户端和服务器端的网络连接。
                </p>

                <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                  <div class="bg-blue-50 p-4 rounded-lg">
                    <h5 class="font-semibold text-blue-800 mb-3">
                      <i class="fas fa-network-wired mr-2"></i>TCP代理实现
                    </h5>
                    <p class="text-sm text-blue-700 mb-2">
                      创建
                      <code>SOCK_STREAM</code>类型的套接字，绑定到12345端口，调用
                      <code>listen()</code>方法监听传入连接。
                    </p>
                    <div class="text-xs text-blue-600">
                      <i class="fas fa-check-circle mr-1"></i>
                      多线程处理并发连接
                    </div>
                  </div>

                  <div class="bg-green-50 p-4 rounded-lg">
                    <h5 class="font-semibold text-green-800 mb-3">
                      <i class="fas fa-paper-plane mr-2"></i>UDP代理实现
                    </h5>
                    <p class="text-sm text-green-700 mb-2">
                      创建
                      <code>SOCK_DGRAM</code>类型的套接字，通过
                      <code>recvfrom()</code>接收数据报。
                    </p>
                    <div class="text-xs text-green-600">
                      <i class="fas fa-check-circle mr-1"></i>
                      维护会话映射表
                    </div>
                  </div>
                </div>
              </div>

              <div class="bg-amber-50 border border-amber-200 rounded-lg p-6 mb-8">
                <h4 class="text-lg font-semibold text-amber-800 mb-4 flex items-center">
                  <i class="fas fa-exclamation-triangle mr-3"></i>
                  获取原始目标地址的难点
                </h4>
                <p class="text-amber-700 mb-4">
                  在实现透明代理的核心功能时，一个至关重要的技术挑战是如何在数据包被重定向到代理服务器后，仍然能够准确地获取其最初的目标地址。
                </p>

                <div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
                  <div class="bg-white p-4 rounded border border-amber-200">
                    <h5 class="font-semibold text-amber-800 mb-3">
                      <i class="fab fa-linux mr-2"></i>Linux环境解决方案
                    </h5>
                    <p class="text-sm text-amber-700 mb-3">
                      使用
                      <code>SO_ORIGINAL_DST</code>套接字选项，通过
                      <code>getsockopt()</code>函数检索原始目标地址。
                    </p>
                    <a href="https://blog.csdn.net/weixin_34274029/article/details/91714031" class="citation text-xs">[Linux实现参考]</a>
                  </div>

                  <div class="bg-white p-4 rounded border border-amber-200">
                    <h5 class="font-semibold text-amber-800 mb-3">
                      <i class="fab fa-windows mr-2"></i>Windows环境挑战
                    </h5>
                    <p class="text-sm text-amber-700 mb-3">
                      Windows缺乏
                      <code>SO_ORIGINAL_DST</code>等效选项，需要依赖WFP或NDIS等底层技术。
                    </p>
                    <a href="https://segmentfault.com/q/1010000016236787" class="citation text-xs">[Windows解决方案]</a>
                  </div>
                </div>
              </div>

              <div>
                <h4 class="text-lg font-semibold text-gray-800 mb-4">基于
                  <code class="bg-gray-100 px-2 py-1 rounded text-sm">scapy</code>的数据包解析与转发
                </h4>
                <p class="text-gray-600 mb-4">
                  <code class="bg-gray-100 px-2 py-1 rounded">scapy</code>是一个功能强大的Python库，用于网络数据包的创建、发送、嗅探和解析，允许在更低的网络层次上进行操作。
                </p>

                <div class="space-y-4">
                  <div class="flex items-start space-x-4">
                    <div class="flex-shrink-0 w-8 h-8 bg-purple-100 rounded-full flex items-center justify-center">
                      <i class="fas fa-search text-purple-600 text-sm"></i>
                    </div>
                    <div>
                      <h5 class="font-semibold text-gray-800 mb-2">捕获与解析IP、TCP、UDP头部</h5>
                      <p class="text-sm text-gray-600 mb-2">
                        使用
                        <code>sniff()</code>函数和BPF过滤器捕获特定流量，通过分层对象模型访问各协议头部字段。
                      </p>
                      <a href="https://docs.pingcode.com/baike/909167" class="citation text-xs">[Scapy使用指南]</a>
                    </div>
                  </div>

                  <div class="flex items-start space-x-4">
                    <div class="flex-shrink-0 w-8 h-8 bg-green-100 rounded-full flex items-center justify-center">
                      <i class="fas fa-cogs text-green-600 text-sm"></i>
                    </div>
                    <div>
                      <h5 class="font-semibold text-gray-800 mb-2">数据包重构与校验和计算</h5>
                      <p class="text-sm text-gray-600">
                        修改IP头部和TCP/UDP头部的目的地址和端口，通过设置校验和为
                        <code>None</code>让scapy自动重新计算。
                      </p>
                    </div>
                  </div>
                </div>
              </div>
            </div>

            <!-- Code Implementation -->
            <div id="server-code" class="section-card p-8">
              <h3 class="serif-heading text-2xl font-bold text-gray-900 mb-6">1.3 代码实现方案</h3>

              <div class="space-y-8">
                <div>
                  <h4 class="text-lg font-semibold text-gray-800 mb-4">方案一：基于
                    <code class="bg-gray-100 px-2 py-1 rounded text-sm">socket</code>的多线程代理
                  </h4>

                  <div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
                    <div class="bg-blue-50 p-4 rounded-lg">
                      <h5 class="font-semibold text-blue-800 mb-3">TCP代理处理流程</h5>
                      <div class="space-y-2 text-sm">
                        <div class="flex items-center">
                          <span class="w-6 h-6 bg-blue-500 text-white rounded-full flex items-center justify-center text-xs mr-3">1</span>
                          <span class="text-blue-700">创建TCP套接字并绑定到12345端口</span>
                        </div>
                        <div class="flex items-center">
                          <span class="w-6 h-6 bg-blue-500 text-white rounded-full flex items-center justify-center text-xs mr-3">2</span>
                          <span class="text-blue-700">调用
                            <code>listen()</code>开始监听连接
                          </span>
                        </div>
                        <div class="flex items-center">
                          <span class="w-6 h-6 bg-blue-500 text-white rounded-full flex items-center justify-center text-xs mr-3">3</span>
                          <span class="text-blue-700">使用
                            <code>accept()</code>接收客户端连接
                          </span>
                        </div>
                        <div class="flex items-center">
                          <span class="w-6 h-6 bg-blue-500 text-white rounded-full flex items-center justify-center text-xs mr-3">4</span>
                          <span class="text-blue-700">创建新线程处理客户端请求</span>
                        </div>
                        <div class="flex items-center">
                          <span class="w-6 h-6 bg-blue-500 text-white rounded-full flex items-center justify-center text-xs mr-3">5</span>
                          <span class="text-blue-700">建立与目标服务器的连接</span>
                        </div>
                      </div>
                      <a href="https://juejin.cn/post/7511560864223985664" class="citation text-xs mt-3 inline-block">[多线程代理实现]</a>
                    </div>

                    <div class="bg-green-50 p-4 rounded-lg">
                      <h5 class="font-semibold text-green-800 mb-3">UDP代理处理流程</h5>
                      <div class="space-y-2 text-sm">
                        <div class="flex items-center">
                          <span class="w-6 h-6 bg-green-500 text-white rounded-full flex items-center justify-center text-xs mr-3">1</span>
                          <span class="text-green-700">创建UDP套接字并绑定到12345端口</span>
                        </div>
                        <div class="flex items-center">
                          <span class="w-6 h-6 bg-green-500 text-white rounded-full flex items-center justify-center text-xs mr-3">2</span>
                          <span class="text-green-700">使用
                            <code>recvfrom()</code>接收数据报
                          </span>
                        </div>
                        <div class="flex items-center">
                          <span class="w-6 h-6 bg-green-500 text-white rounded-full flex items-center justify-center text-xs mr-3">3</span>
                          <span class="text-green-700">获取发送方地址信息</span>
                        </div>
                        <div class="flex items-center">
                          <span class="w-6 h-6 bg-green-500 text-white rounded-full flex items-center justify-center text-xs mr-3">4</span>
                          <span class="text-green-700">维护客户端到目标服务器的映射</span>
                        </div>
                        <div class="flex items-center">
                          <span class="w-6 h-6 bg-green-500 text-white rounded-full flex items-center justify-center text-xs mr-3">5</span>
                          <span class="text-green-700">转发数据报并处理响应</span>
                        </div>
                      </div>
                      <a href="https://www.cnblogs.com/MikeZhang/archive/2012/10/15/udpProxyServer20121015.html" class="citation text-xs mt-3 inline-block">[UDP代理实现]</a>
                    </div>
                  </div>
                </div>

                <div>
                  <h4 class="text-lg font-semibold text-gray-800 mb-4">方案二：基于
                    <code class="bg-gray-100 px-2 py-1 rounded text-sm">scapy</code>的原始套接字代理
                  </h4>

                  <div class="bg-purple-50 p-6 rounded-lg">
                    <div class="grid grid-cols-1 md:grid-cols-3 gap-6">
                      <div class="text-center">
                        <div class="w-12 h-12 bg-purple-500 text-white rounded-full flex items-center justify-center mx-auto mb-3">
                          <i class="fas fa-search"></i>
                        </div>
                        <h5 class="font-semibold text-purple-800 mb-2">数据包嗅探与过滤</h5>
                        <p class="text-sm text-purple-700">
                          使用
                          <code>sniff()</code>函数和BPF过滤器捕获特定流量
                        </p>
                        <a href="https://www.cnblogs.com/N3ptune/p/16322703.html" class="citation text-xs mt-2 inline-block">[Scapy嗅探示例]</a>
                      </div>

                      <div class="text-center">
                        <div class="w-12 h-12 bg-purple-500 text-white rounded-full flex items-center justify-center mx-auto mb-3">
                          <i class="fas fa-edit"></i>
                        </div>
                        <h5 class="font-semibold text-purple-800 mb-2">数据包修改与发送</h5>
                        <p class="text-sm text-purple-700">
                          修改IP头部和TCP/UDP头部，重新计算校验和
                        </p>
                      </div>

                      <div class="text-center">
                        <div class="w-12 h-12 bg-purple-500 text-white rounded-full flex items-center justify-center mx-auto mb-3">
                          <i class="fas fa-paper-plane"></i>
                        </div>
                        <h5 class="font-semibold text-purple-800 mb-2">透明代理实现</h5>
                        <p class="text-sm text-purple-700">
                          通过
                          <code>send()</code>函数将修改后的数据包发送出去
                        </p>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </section>

      <!-- Client Implementation Section -->
      <section id="client-implementation" class="py-16 bg-gray-50">
        <div class="container mx-auto px-8">
          <div class="max-w-4xl mx-auto">
            <div class="text-center mb-12">
              <h2 class="serif-heading text-4xl font-bold text-gray-900 mb-4">2. 客户端：Windows进程流量拦截与重定向</h2>
              <p class="text-xl text-gray-600 leading-relaxed">在Windows平台上实现特定进程的网络流量拦截、修改和重定向</p>
            </div>

            <!-- Client Core Functionality -->
            <div id="client-core" class="section-card p-8 mb-12">
              <h3 class="serif-heading text-2xl font-bold text-gray-900 mb-6">2.1 核心功能与架构</h3>

              <div class="grid grid-cols-1 md:grid-cols-2 gap-8 mb-8">
                <div>
                  <h4 class="text-lg font-semibold text-gray-800 mb-4 flex items-center">
                    <i class="fas fa-user-shield text-red-500 mr-3"></i>
                    管理员权限运行
                  </h4>
                  <p class="text-gray-600 mb-4">
                    客户端程序必须在<strong class="text-red-600">Windows管理员身份下运行</strong>，因为需要执行底层的网络操作，如拦截和修改其他进程的网络数据包。
                  </p>
                  <div class="bg-red-50 p-4 rounded-lg border-l-4 border-red-500">
                    <p class="text-sm text-red-800">
                      <i class="fas fa-exclamation-triangle mr-2"></i>
                      客户端将使用
                      <code>pydivert</code>库，该库依赖于
                      <code>WinDivert</code>驱动程序，需要管理员权限才能加载。
                    </p>
                  </div>
                </div>

                <div>
                  <h4 class="text-lg font-semibold text-gray-800 mb-4 flex items-center">
                    <i class="fas fa-crosshairs text-blue-500 mr-3"></i>
                    根据进程名或PID捕获目标进程
                  </h4>
                  <p class="text-gray-600 mb-4">
                    客户端需要能够根据用户输入的<strong class="text-blue-600">进程名称</strong>或<strong class="text-blue-600">进程ID（PID）</strong>来定位目标进程。
                  </p>
                  <div class="space-y-3">
                    <div class="flex items-center space-x-3">
                      <div class="w-8 h-8 bg-blue-100 rounded-full flex items-center justify-center">
                        <i class="fas fa-file-code text-blue-600 text-sm"></i>
                      </div>
                      <span class="text-sm text-gray-700">进程名称匹配（如
                        <code>chrome.exe</code>）
                      </span>
                    